package Touchy;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * The endgamepanel shows the score acieed in the gamepanel.
 * It alows you ot return to the menu.
 * 
 * @author Sletten
 *
 */

@SuppressWarnings("serial")
public class EndGamePanel extends JPanel implements ActionListener
{
	private Touchy mTouchy;
	
	private JLabel mScore;
	
	public EndGamePanel(Touchy inTouchy)
	{
		mTouchy = inTouchy;
		
		this.setLayout(null);
		this.setPreferredSize(new Dimension(800,600));
		this.setBackground(Color.decode("#BFD657"));
		
		//game over
		JLabel label = new JLabel("Game Over!");
		label.setFont(new Font("Arial", Font.PLAIN, 100));
		label.setBounds(this.getPreferredSize().width/2-(label.getPreferredSize().width/2), 50, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		//score
		mScore = new JLabel("Score: 0");
		mScore.setFont(new Font("Arial", Font.PLAIN, 40));
		mScore.setBounds(this.getPreferredSize().width/2-(mScore.getPreferredSize().width/2), 200, mScore.getPreferredSize().width, mScore.getPreferredSize().height);
		this.add(mScore);
		
		
		//back to menu
		JButton button = new JButton("Back to menu");
		button.setFont(new Font("Arial", Font.PLAIN, 25));
		button.setBounds(this.getPreferredSize().width/2-(button.getPreferredSize().width/2), 300, button.getPreferredSize().width, button.getPreferredSize().height);
		button.setActionCommand("backtothefuture");
		button.addActionListener(this);
		this.add(button);

	}
	
	public void setScore(int inScore)
	{
		mScore.setText("Score: "+Integer.toString(inScore));
		//setting the label centered
		mScore.setBounds(this.getPreferredSize().width/2-(mScore.getPreferredSize().width/2), 200, mScore.getPreferredSize().width, mScore.getPreferredSize().height);
	}
	
	public void run()
	{
	}

	public void actionPerformed(ActionEvent e)
	{
		if("backtothefuture".equals(e.getActionCommand()))
		{
			mTouchy.setState(mTouchy.MENU);
		}
	}
}
